package com.zengqingfa.fastdfs.rest;

import com.github.tobato.fastdfs.domain.fdfs.FileInfo;
import com.zengqingfa.fastdfs.service.FastDfsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author zengqingfa
 * @className FastDfsRest
 * @description
 * @create 2021/11/20 17:36
 */
@RestController
@RequestMapping("/fastdfs")
public class FastDfsRest {

    @Autowired
    FastDfsService fastDfsService;

    @GetMapping("/uploadFile")
    public String uploadFile(@RequestPart(value = "file",required = true) MultipartFile file) {
        return fastDfsService.uploadFile(file);
    }


    @GetMapping("/downloadFile")
    public void downloadFile( @RequestParam("url") String url) {
        fastDfsService.downloadFile( url);
    }

    @GetMapping("/deleteFile")
    public void deleteFile(@RequestParam("url") String url) {
        fastDfsService.deleteFile(url);
    }


    @GetMapping("/queryFileInfo")
    public FileInfo queryFileInfo(@RequestParam("url") String url) {
       return fastDfsService.queryFileInfo(url);
    }
}